﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HalfNetworkNET;


namespace Console_EchoServer
{
    public class EchoServer : HNNServer
    {
        public override bool Run()
        {
            base.Run();
            return true;
        }

        public override ushort AddTimers()
        {
            return HalfNetworkNET.ERRORCODE.NONE;
        }

        protected override void OnAccept_Client(uint StreamID, string IP)
        {
            Console.WriteLine("Clietn Accept : StreamID:{0}, IP:{1}", StreamID, IP);
        }

        protected override void OnRead_Client(uint StreamID, byte[] recvdata)
        {
            Send(StreamID, recvdata.Length, recvdata);
        }

        protected override void OnDisConnect_Client(uint StreamID)
        {
            Console.WriteLine("Clietn Disconnected : StreamID:{0}", StreamID);
        }

        protected override void OnAccept_Server(uint StreamID, string IP)
        {
            Console.WriteLine("Server Accept : StreamID:{0}, IP:{1}", StreamID, IP);
        }

        protected override void OnRead_Server(uint nStreamID, byte[] recvdata)
        {
            Send(nStreamID, recvdata.Length, recvdata);
        }

        protected override void OnDisConnect_Server(uint StreamID)
        {
            Console.WriteLine("Server Disconnected : StreamID:{0}", StreamID);
        }

        protected override void OnTimer(uint TimerID)
        {
            Console.WriteLine("OnTimer : TimerID:{0}", TimerID);
        }
    }
}
